package com.leyou.item.controller;

import com.leyou.item.dto.SpecParamDTO;
import com.leyou.item.service.ISpecParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/spec")
public class SpecParamController {
    @Autowired
    private ISpecParamService specParamService;

    /**
     * 根据规格分组的gid、分类的cid、是否需要被搜索searching，查询规格参数param
     * @param gid
     * @param cid
     * @param searching
     * @return
     */
    @GetMapping("/params")
    public ResponseEntity<List<SpecParamDTO>> querySpecParams(
            @RequestParam(value = "gid", required = false) Long gid,
            @RequestParam(value = "cid",required = false) Long cid,
            @RequestParam(value = "searching",required = false)Boolean searching
            ) {
        return ResponseEntity.ok(specParamService.querySpecParams(gid,cid,searching));
    }
}
